package edu.wpi.cs509.ui;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;
public class MidGameAdapter extends MouseAdapter {
    private GameBoardPanel board;
    private GameBoardSquare square;
    private GameBoardNotify event;
    
    public MidGameAdapter(GameBoardPanel board, GameBoardSquare square, GameBoardNotify event){
    	this.board=board;
    	this.square=square;
    	this.event=event;
    }
    public void mouseClicked(MouseEvent e) {
    	System.out.println("x");
    	if(board.getBoardSquareIndex(square) == 42 ||
    			board.getBoardSquareIndex(square) == 43 ||
    			board.getBoardSquareIndex(square) == 46 ||
    			board.getBoardSquareIndex(square) == 47 ||
    			board.getBoardSquareIndex(square) == 52 ||
    			board.getBoardSquareIndex(square) == 53 ||
    			board.getBoardSquareIndex(square) == 56 ||
    			board.getBoardSquareIndex(square) == 57) {
    		JOptionPane.showMessageDialog(square, "Error: Your soldiers cannot swim.",
    				"Error",JOptionPane.ERROR_MESSAGE);
    		return;
    	}
    	event.pieceSelected(square);
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        //componentColor = componentColor.brighter();
        //repaint();
    }

    @Override
    public void mouseExited(MouseEvent e) {
        //componentColor = new Color(232, 143, 23);
        //repaint();
    }
}
